home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / sphsrc / sph_stat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  1.7 KB  |  91 lines

  1. #include "HEADERS.h"
  2. #define SPHIGS_BOSS
  3. #include "sphigslocal.h"
  4. #include <math.h>
  5.  
  6.  
  7.  
  8.  
  9. static int
  10. ResizeCallback (int width, int height)
  11. {
  12.    register vi;
  13.  
  14.    SPH_ndcSpaceSizeInPixels = (width>height) ? height : width;
  15.    for (vi=0; vi<=MAX_VIEW_INDEX; vi++) {
  16.       SPH__updateViewInfo (vi);
  17.       SPH__refresh_viewport_change (vi, SPH_viewTable[vi].pdc_viewport);
  18.    }
  19. }
  20.  
  21.  
  22.  
  23. /*!*/
  24. void SPH_begin (int width, int height, int color_planes_desired,
  25.         int shades_per_flexicolor)
  26. {
  27.    if (SPH__enabled)
  28.       SPH__error (ERR_ALREADY_ENABLED);
  29.  
  30.    SPH__enabled = TRUE;
  31.  
  32.    /* What should be the size in pixels of 1 NPC unit? */
  33.    SPH_ndcSpaceSizeInPixels = (width>height) ? height : width;
  34.  
  35.    SRGP_begin ("SPHIGS", width, height, color_planes_desired, FALSE);
  36.  
  37.    ALLOC_RECORDS (SPH_viewTable, view_spec, MAX_VIEW_INDEX+1);
  38.    ALLOC_RECORDS (SPH__structureTable, structure, MAX_STRUCTURE_ID+1);
  39.  
  40.    BYTES_PER_BITSTRING = ceil((MAX_STRUCTURE_ID+1.0)/8.0);
  41.  
  42.    SRGP_allowResize (TRUE);
  43.    SRGP_registerResizeCallback (ResizeCallback);
  44.  
  45.    SPH__init_structure_table();
  46.    SPH__initDefaultAttributeGroup();
  47.    SPH__init_view_table();
  48.  
  49.    SPH_setImplicitRegenerationMode (ALLOWED);
  50.  
  51.    SPH__initColorTable (shades_per_flexicolor);
  52. }
  53.  
  54.  
  55.  
  56.  
  57. /*!*/
  58. void
  59. SPH_end()
  60. {
  61.    SRGP_end();
  62.    SPH__enabled = FALSE;
  63. }
  64.  
  65.  
  66.  
  67.  
  68. /** ROUTINES ALLOWING APPLICATION TO CHANGE SIZES OF TABLES
  69. These may only be called *before* SPHIGS is enabled.
  70. **/
  71.  
  72. static void CheckNotEnabledYet (void)
  73. {
  74.    if (SPH__enabled)
  75.       SPH__error (ERR_ALREADY_ENABLED);
  76. }
  77.  
  78.  
  79. void SPH_setMaxStructureID (int i)
  80. {
  81.    CheckNotEnabledYet();
  82.    MAX_STRUCTURE_ID = i;
  83. }
  84.  
  85.  
  86. void SPH_setMaxViewIndex (int i)
  87. {
  88.    CheckNotEnabledYet();
  89.    MAX_VIEW_INDEX = i;
  90. }
  91.